package test;

import javax.microedition.lcdui.Graphics;
import org.xmap.ui.View;
import org.xmap.ui.ViewManager;
import org.xmap.ui.base.Window;
import org.xmap.ui.control.Bitmap;

public class LogoView extends View {

    private Bitmap logo;
    private long startTime;

    public LogoView() {
//        this.setShowTitle(false);
        this.logo = new Bitmap("/xmapres/XmapBrand.png", 0, 0, this.getRect().width, this.getRect().height,
                Window.ORIENT_LEFT_UP);
        this.logo.setBgColor(0xFFFF0000);
        this.addControls(this.logo);
        this.startTime = System.currentTimeMillis();
    }

    public void draw(Graphics g) {
        g.setColor(0);
        g.drawString("按任意键继续", this.getRect().width >> 1,
                this.getRect().height - 20, Graphics.HCENTER | Graphics.BOTTOM);
    }

    public boolean keyEvent(boolean flag, int keyCode, int gameAction) {
        if (flag) {
            ViewManager.instance.setView(new XmapDemoView(), View.ANIMATION_RIGHT_TO_LEFT);
        }
        return true;
    }

    public void update() {
        if (System.currentTimeMillis() - this.startTime > 3000) {
            ViewManager.instance.setView(new XmapDemoView(), View.ANIMATION_RIGHT_TO_LEFT);
        }
    }
}
